l = []
s = int(input())
while s != 0:
    l.append(s)
    s = int(input())
length = len(l)
mark = l[0]
l.sort()
n = l.index(mark)+1
if length%2==0:
    if n <=length/2:
        print('BOTTOM')
    elif n > length/2:
        print('TOP')
else:
    if n <round(length/2):
        print('BOTTOM')
    elif n > round(length/2):
        print('TOP')
    else:
        print('MIDDLE')
